
package com.wobaby.security;

import com.wobaby.util.RenditionUncheckedException;

// Referenced classes of package com.wobaby.security:
//            PermissionEntry

public class PermissionException extends RenditionUncheckedException
{

    public PermissionException()
    {
    }

    public PermissionException(Exception t)
    {
        super(t);
    }

    public PermissionException(String m)
    {
        super(m);
    }

    public PermissionException(int type)
    {
        this.type = type;
    }

    public Object getResource()
    {
        return resource;
    }

    public void setResource(Object newResource)
    {
        resource = newResource;
    }

    public void setPermissionEntry(PermissionEntry permissionEntry)
    {
        this.permissionEntry = permissionEntry;
    }

    public PermissionEntry getPermissionEntry()
    {
        return permissionEntry;
    }

    public void setType(int type)
    {
        this.type = type;
    }

    public int getType()
    {
        return type;
    }

    public String getMessage()
    {
        return getDescription();
    }

    public String getDescription()
    {
        Object op = permissionEntry != null ? ((Object) (permissionEntry.name)) : getResource();
        
        String detail = "auth/no_privilege" + op;
        /*String message = super.getMessage();
        if(message != null && !message.trim().equals(""))
            detail = message;*/
        switch(getType())
        {
        case 7: // '\007'
            detail = "auth/no_privilege"+op;
            break;

        case 1: // '\001'
            detail = "auth/no_device_permission"+op;
            break;

        case 2: // '\002'
            detail = "auth/no_group_permission"+op;
            break;

        case 9: // '\t'
            detail = "auth/no_script_permission"+op;
            break;

        case 3: // '\003'
            detail = "auth/resource_undefined"+op;
            break;

        case 5: // '\005'
            detail = "auth/not_owner_of_resource"+op;
            break;

        case 12: // '\f'
            detail = "auth/no_script_permission_at_all"+op;
            break;

        case 11: // '\013'
            detail = "auth/no_mdp_at_all"+op;
            break;

        case 6: // '\006'
            detail = "auth/no_login"+op;
            break;
        }
        return detail;
    }

    public static final int OK = 0;
    public static final int NO_PRIVILEGE = 7;
    public static final int DENIED = 7;
    public static final int NO_DEVICE_MCP = 1;
    public static final int NO_DEVICE_GROUP_MCP = 2;
    public static final int PERMISSION_NOT_DEFINED = 3;
    public static final int NO_TASK_PERMISSION = 4;
    public static final int NOT_OWNER = 5;
    public static final int NO_LOGIN = 6;
    public static final int NO_SCRIPT_PERMISSION = 9;
    public static final int NO_MDP_AT_ALL = 11;
    public static final int NO_SCRIPT_PERMISSION_AT_ALL = 12;
    public static final int MDP = 11;
    public static final int NO_USERID = 13;
    public static final int NO_CHECKER_DEFINED = 10;
    public static final int MCP_PERMISSION_REQUIRED = -5;
    public static final int OWNERSHIP_REQUIRED = -4;
    public static final int CUSTOM_CHECK_REQUIRED = -6;
    public static final int SCRIPT_PERMISSION_REQUIRED = -7;
    private PermissionEntry permissionEntry;
    private int type;
    private Object resource;
}